* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: '华文仿宋', 'STFangsong', 'serif', 'Arial', sans-serif;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.3) 0%, rgba(22, 33, 62, 0.3) 25%, rgba(15, 52, 96, 0.3) 50%, rgba(83, 52, 131, 0.3) 75%, rgba(114, 9, 183, 0.3) 100%);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    color: #f0f0f0;
    position: relative;
    overflow-x: hidden;
    transition: background-image 0.8s ease-in-out, background-color 0.8s ease-in-out;
}

/* 当设置了背景图片时，覆盖默认渐变 */
body.has-background {
    background: rgba(255, 255, 255, 0.1);
}

/* 修仙背景动画 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(255, 215, 0, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(138, 43, 226, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(30, 144, 255, 0.1) 0%, transparent 50%);
    animation: immortalFlow 15s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes immortalFlow {
    0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
    25% { transform: translate(-20px, -20px) scale(1.1) rotate(90deg); }
    50% { transform: translate(20px, -10px) scale(0.9) rotate(180deg); }
    75% { transform: translate(-10px, 20px) scale(1.05) rotate(270deg); }
}

.game-container {
    background: rgba(255, 255, 255, 0.1);
    background-image: url('./background/step-6.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 0;
    padding: 20px;
    backdrop-filter: blur(5px);
    box-shadow: 
        0 0 30px rgba(255, 215, 0, 0.3),
        inset 0 0 20px rgba(255, 215, 0, 0.1);
    width: 100vw;
    height: 100vh;
    margin: 0;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    backdrop-filter: blur(10px);
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    font-size: 2.5em;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(255, 215, 0, 0.5);
    margin-bottom: 20px;
    animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from { text-shadow: 2px 2px 4px rgba(255, 215, 0, 0.5); }
    to { text-shadow: 2px 2px 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.6); }
}

.cultivation-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.realm {
    flex: 1;
    text-align: left;
}

.realm-label {
    color: #ccc;
    font-size: 0.9em;
}

.realm-name {
    color: #ffd700;
    font-weight: bold;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(255, 215, 0, 0.5);
}

.experience {
    flex: 2;
    display: flex;
    align-items: center;
    gap: 10px;
}

.exp-label {
    color: #ccc;
    font-size: 0.9em;
    white-space: nowrap;
}

.exp-bar {
    flex: 1;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #ffd700;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.exp-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #ffed4e, #ffd700);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    animation: expGlow 1.5s ease-in-out infinite alternate;
}

@keyframes expGlow {
    from { box-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
    to { box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.2); }
}

.exp-text {
    color: #ffd700;
    font-size: 0.9em;
    white-space: nowrap;
}

.score-board {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1em;
}

.score, .high-score {
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.score span, .high-score span {
    color: #ffd700;
    font-weight: bold;
}

.game-area {
    position: relative;
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

#gameCanvas {
    border: 3px solid #ffd700;
    border-radius: 15px;
    background: transparent;
    box-shadow: 
        0 0 20px rgba(255, 215, 0, 0.3),
        inset 0 0 50px rgba(255, 215, 0, 0.1);
}

.realm-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.95), rgba(255, 140, 0, 0.95));
    color: #000;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    border: 3px solid #ffd700;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.8);
    display: none;
    z-index: 1000;
    animation: realmBreakthrough 3s ease-in-out;
}

@keyframes realmBreakthrough {
    0% { 
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
    100% { 
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.notification-content h2 {
    font-size: 2em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.notification-content p {
    font-size: 1.2em;
    font-weight: bold;
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    border-radius: 15px;
    z-index: 999;
}

.overlay-content {
    background: linear-gradient(135deg, #1a1a2e, #533483);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    border: 2px solid #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.overlay-content h2 {
    color: #ffd700;
    font-size: 1.8em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}

.overlay-content p {
    color: #fff;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.control-info {
    text-align: center;
    color: #ccc;
}

.cultivation-tip {
    color: #ffd700 !important;
    font-weight: bold;
    margin-top: 5px !important;
}

.speed-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.speed-control label {
    color: #ffd700;
    font-weight: bold;
}

.speed-slider {
    width: 200px;
    height: 8px;
    background: rgba(255, 215, 0, 0.3);
    outline: none;
    border-radius: 5px;
}

.speed-slider::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    background: #ffd700;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.difficulty-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
}

.difficulty-control label {
    color: #ffd700;
    font-weight: bold;
}

.difficulty-select {
    width: 220px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #ffd700;
    border-radius: 8px;
    color: #ffd700;
    font-size: 14px;
    outline: none;
    cursor: pointer;
}

.difficulty-select:focus {
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.difficulty-select option {
    background: #1a1a1a;
    color: #ffd700;
    padding: 5px;
}

.control-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.btn {
    padding: 12px 24px;
    border: 2px solid #ffd700;
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.btn:hover {
    background: rgba(255, 215, 0, 0.2);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    transform: translateY(-2px);
}

.btn.primary {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #000;
    border-color: #ffd700;
}

.btn.primary:hover {
    background: linear-gradient(135deg, #ffed4e, #ffd700);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.7);
}

.btn.active {
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
    color: #fff;
    border-color: #ff6b6b;
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.5);
}

.btn.active:hover {
    background: linear-gradient(135deg, #ff8e8e, #ff6b6b);
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.7);
}

.realm-guide {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 215, 0, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.realm-guide h3 {
    color: #ffd700;
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.3em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.realm-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.realm-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    transition: all 0.3s ease;
}

.realm-item:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.5);
    transform: translateY(-2px);
}

.realm-icon {
    font-size: 1.2em;
}

.realm-item .realm-name {
    color: #ffd700;
    font-weight: bold;
    flex: 1;
}

.realm-desc {
    color: #ccc;
    font-size: 0.9em;
}

/* 游戏状态控制 */
.game-started .controls,
.game-started .realm-guide {
    display: none;
}

/* 游戏区域默认隐藏，只有开始游戏后才显示 */
.game-container .game-area {
    display: none;
}

.game-container.game-started {
    background-image: none;
}
.game-container.game-started .game-area {
    margin-bottom: 0;
    display: flex !important;
}

.game-container:not(.game-started) .game-header {
    margin-bottom: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    
    .game-header h1 {
        font-size: 2em;
    }
    
    #gameCanvas {
        width: 100%;
        max-width: 400px;
        height: auto;
    }
    
    .cultivation-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .experience {
        width: 100%;
    }
    
    .realm-list {
        grid-template-columns: 1fr;
    }
    
    .control-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .skills-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    .skill-item {
        padding: 8px !important;
    }
    
    .skill-icon {
        font-size: 20px !important;
    }
    
    .skill-name {
        font-size: 12px !important;
    }
    
    .skill-realm {
        font-size: 10px !important;
    }
    
    .skill-cooldown {
        font-size: 10px !important;
    }
}

/* 技能UI界面样式 */
.skills-panel {
    position: fixed;
    top: 10px;
    left: 10px;
    width: 200px;
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid #FFD700;
    border-radius: 6px;
    padding: 8px;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 15px rgba(255, 215, 0, 0.3);
    z-index: 1000;
}

.skills-panel h3 {
    color: #FFD700;
    text-align: center;
    margin-bottom: 10px;
    font-size: 16px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.skills-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.skill-item {
    position: relative;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    overflow: hidden;
}

.skill-item:hover {
    border-color: #FFD700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    transform: translateY(-2px);
}

.skill-item.available {
    border-color: #00FF00;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.skill-item.unavailable {
    opacity: 0.5;
    cursor: not-allowed;
}

.skill-item.cooldown {
    border-color: #FF6B6B;
    opacity: 0.7;
}

.skill-icon {
    font-size: 18px;
    margin-bottom: 3px;
    display: block;
}

.skill-name {
    color: #FFD700;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 2px;
}

.skill-realm {
    color: #87CEEB;
    font-size: 10px;
    margin-bottom: 3px;
}

.skill-cooldown {
    color: #FFF;
    font-size: 9px;
    font-weight: bold;
}

.skill-cooldown.ready {
    color: #00FF00;
}

.skill-cooldown.cooling {
    color: #FF6B6B;
}

.skill-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.skill-item.cooldown .skill-overlay {
    opacity: 1;
}

.skill-tips {
    border-top: 1px solid rgba(255, 215, 0, 0.3);
    padding-top: 8px;
    text-align: center;
}

.skill-tips p {
    color: #87CEEB;
    font-size: 10px;
    margin: 1px 0;
}

/* 技能激活动画 */
@keyframes skillActivation {
    0% { transform: scale(1); box-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
    50% { transform: scale(1.1); box-shadow: 0 0 25px rgba(255, 215, 0, 0.8); }
    100% { transform: scale(1); box-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
}

.skill-item.activating {
    animation: skillActivation 0.6s ease-in-out;
}

/* 技能通知动画 */
@keyframes skillNotification {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* 被动技能样式 */
.skill-cooldown.passive {
    color: #4CAF50;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
}

/* 虚拟方向按键样式 */
.virtual-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: none; /* 默认隐藏，只在移动端显示 */
    z-index: 100;
}

.virtual-dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.virtual-middle {
    display: flex;
    gap: 60px;
    align-items: center;
}

.virtual-btn {
    width: 60px;
    height: 60px;
    border: 2px solid #ffd700;
    background: rgba(255, 215, 0, 0.2);
    color: #ffd700;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.virtual-btn:active {
    background: rgba(255, 215, 0, 0.5);
    transform: scale(0.95);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

.virtual-btn:hover {
    background: rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

/* 移动端响应式布局 */
@media screen and (max-width: 768px) {
    .game-container {
        padding: 0 !important;
        overflow: hidden;
    }
    
    .game-header h1 {
        font-size: 1.8em;
        margin-bottom: 10px;
    }
    
    .cultivation-info {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 10px;
        padding: 8px;
    }
    
    .score-board {
        flex-direction: column;
        gap: 5px;
        font-size: 0.9em;
    }
    
    #gameCanvas {
        width: 100% !important;
        height: auto !important;
        max-width: 100vw;
        max-height: 50vh;
    }
    
    /* 移动端显示虚拟按键 */
    .virtual-controls {
        display: block !important;
        bottom: -172px;
        right: 30px;
    }
    
    /* 移动端缩小技能面板 */
    .skills-panel {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
    }
    
    .skills-container {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    
    .skill-item {
        width: 80px !important;
        height: 80px !important;
        padding: 5px !important;
    }
    
    .skill-icon {
        font-size: 20px !important;
    }
    
    .skill-name {
        font-size: 10px !important;
        margin: 2px 0 !important;
    }
    
    .skill-realm {
        font-size: 8px !important;
    }
    
    .skill-cooldown {
        font-size: 8px !important;
    }
    
    .skill-tips {
        display: none; /* 移动端隐藏按键提示 */
    }
    
    .controls {
        gap: 10px;
    }
    
    .speed-control, .difficulty-control {
        gap: 5px;
    }
    
    .speed-slider {
        width: 150px;
    }
    
    .difficulty-select {
        width: 180px;
        font-size: 12px;
    }
    
    .control-buttons {
        gap: 10px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 0.9em;
    }
    
    .realm-guide {
        margin-top: 15px;
    }
    
    .realm-list {
        gap: 8px;
    }
    
    .realm-item {
        padding: 8px;
        font-size: 0.9em;
    }
}

/* 超小屏幕适配 */
@media screen and (max-width: 480px) {
    .virtual-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .virtual-middle {
        gap: 50px;
    }
    
    .skill-item {
        width: 70px !important;
        height: 70px !important;
    }
    
    .skill-icon {
        font-size: 18px !important;
    }
    
    .skill-name {
        font-size: 9px !important;
    }
}